<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>新经资讯后台管理</title>
    <link rel="stylesheet" type="text/css" href="../../static/admin/css/reset.css">
    <link rel="stylesheet" type="text/css" href="../../static/admin/css/main.css">
    <link rel="stylesheet" href="../../static/admin/css/jquery.pagination.css">
    <script type="text/javascript" src="../../static/admin/js/jquery-1.12.4.min.js"></script>
    <script type="text/javascript" src="../../static/admin/js/jquery.pagination.min.js"></script>
</head>
<body>
<div class="breadcrub">
    当前位置：用户管理>用户列表
</div>
<div class="pannel">
    <table class="common_table">
        <tr><th>用户名</th><th>电话</th><th>注册时间</th><th>上次登录时间</th></tr>
        {% for user in collections -%}
            <tr>
                <td>{{ user.nick_name }}</td>
                <td>{{ user.mobile }}</td>
                <td>{{ user.register }}</td>
                <td>{{ user.last_login }}</td>
            </tr>
        {%- endfor %}

    </table>
</div>

<div class="box">
    <div id="pagination" class="page"></div>
</div>


<script>
    $(function () {

        //全局网页跳转，不只是刷新iframe
        $('.article_list').delegate('a', 'click', function () {
            var news_id = $(this).attr('data_newsid');
            window.parent.location.href = "/" + news_id
        });


        // 分页功能
        $("#pagination").pagination({
            currentPage: {{ curr_page }},
            totalPage: {{ total_page }},
            callback: function (current) {
                //window.location.href = "users/follow_list/" + current
                $.ajax({
                    type: "GET",
                    url: "user_list?page=" + current,
                    dataType: "json",
                    success: function (resp) {
                        //拼接html(这个部分根据自己的需求去实现)
                        totalPage = resp.total_page
                        var collections = resp.collections;
                        //console.log(users);
                        var htm = '<tr><th>用户名</th><th>电话</th><th>注册时间</th><th>上次登录时间</th></tr>';

                        collections.forEach(function (elem) {
                            htm += '<tr><td>' + elem.nick_name + '</td><td>' + elem.mobile + '</td><td>' + elem.register + '</td><td>' + elem.last_login + '</td></tr>';
                        });

                        $('.common_table').html(htm)
                    }
                });
            }
        });
    });
</script>
</body>
</html>